package com.qst.action.user;

import com.qst.BaseServlet;
import com.qst.RequestUtil;
import com.qst.WebUtil;
import com.qst.entity.User;
import com.qst.service.impl.ServiceFactory;
import com.qst.service.UserAdminService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet("/user/edit.action")
public class EditServlet extends BaseServlet {

    private UserAdminService userAdminService = ServiceFactory.getService(UserAdminService.class);

    @Override
    protected void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = RequestUtil.getInt(req, "id");
        User user = userAdminService.findById(id);
        req.setAttribute("user", user);
        WebUtil.forward(req, resp, "/user/edit.jsp");
    }
}
